<?php


namespace app\manage\model;


class Category extends BaseModel
{
    public static function getAll()
    {
        return self::all(['parent_id'=>0], 'child');
    }

    public function parentname()
    {
        return $this->belongsTo('Category', 'parent_id', 'id');
    }

    public function child()
    {
        return $this->hasMany('Category', 'parent_id', 'id');
    }
}